package com.such.kit.database.bean;

import java.sql.DatabaseMetaData;
import com.such.kit.database.support.JdbcResultSetMapping;
import com.such.kit.datacast.CastCommons;

/**
 * @author SUCH
 * <pre>
 * 数据库外键元数据
 * 
 * [参考 {@link DatabaseMetaData#getImportedKeys(String, String, String)}]
 * </pre>
 */
public class DatabaseForeignKey implements Comparable<DatabaseForeignKey> {

	/** UPDATE_RULE_NO_ACTION：（importedNoAction）do not allow update of primarykey if it has been imported */
	public static final String UPDATE_RULE_NO_ACTION = "0";
	/** UPDATE_RULE_KEY_CASCADE：（importedKeyCascade）change imported key to agreewith primary key update */
	public static final String UPDATE_RULE_KEY_CASCADE = "1";
	/** UPDATE_RULE_KEY_SET_NULL：（importedKeySetNull）change imported key to NULLif its primary key has been updated */
	public static final String UPDATE_RULE_KEY_SET_NULL = "2";
	/** UPDATE_RULE_KEY_SET_DEFAULT：（importedKeySetDefault）change imported key to default valuesif its primary key has been updated */
	public static final String UPDATE_RULE_KEY_SET_DEFAULT = "3";
	/** UPDATE_RULE_KEY_RESTRICT：（importedKeyRestrict）same as importedKeyNoAction(for ODBC 2.x compatibility) */
	public static final String UPDATE_RULE_KEY_RESTRICT = "4";
	/** DELETE_RULE_NO_ACTION：（importedKeyNoAction）do not allow delete of primarykey if it has been imported */
	public static final String DELETE_RULE_NO_ACTION = "0";
	/** DELETE_RULE_KEY_CASCADE：（importedKeyCascade）delete rows that import a deleted key */
	public static final String DELETE_RULE_KEY_CASCADE = "1";
	/** DELETE_RULE_KEY_SET_NULL：（importedKeySetNull）change imported key to NULL ifits primary key has been deleted */
	public static final String DELETE_RULE_KEY_SET_NULL = "2";
	/** DELETE_RULE_KEY_RESTRICT：（importedKeyRestrict）same as importedKeyNoAction(for ODBC 2.x compatibility) */
	public static final String DELETE_RULE_KEY_RESTRICT = "3";
	/** DELETE_RULE_KEY_SET_DEFAULT：（importedKeySetDefault）change imported key to default ifits primary key has been deleted */
	public static final String DELETE_RULE_KEY_SET_DEFAULT = "4";

	/** pkCatalog：（PKTABLE_CAT）主键表所在编目 */
	@JdbcResultSetMapping("PKTABLE_CAT")
	private String pkCatalog;
	/** pkSchema：（PKTABLE_SCHEM）主键表所在模式 */
	@JdbcResultSetMapping("PKTABLE_SCHEM")
	private String pkSchema;
	/** pkTableName：（PKTABLE_NAME）主键表名 */
	@JdbcResultSetMapping("PKTABLE_NAME")
	private String pkTableName;
	/** pkColumnName：（PKCOLUMN_NAME）主键列名 */
	@JdbcResultSetMapping("PKCOLUMN_NAME")
	private String pkColumnName;
	/** fkCatalog：（FKTABLE_CAT）外键表所在编目 */
	@JdbcResultSetMapping("FKTABLE_CAT")
	private String fkCatalog;
	/** fkSchema：（FKTABLE_SCHEM）外键表所在模式 */
	@JdbcResultSetMapping("FKTABLE_SCHEM")
	private String fkSchema;
	/** fkTableName：（FKTABLE_NAME）外键表名 */
	@JdbcResultSetMapping("FKTABLE_NAME")
	private String fkTableName;
	/** fkColumnName：（FKCOLUMN_NAME）外键列名 */
	@JdbcResultSetMapping("FKCOLUMN_NAME")
	private String fkColumnName;
	/** sequenceNumber：（KEY_SEQ）多个主键时的主键序列 */
	@JdbcResultSetMapping("KEY_SEQ")
	private String sequenceNumber;
	/** updateRule：（UPDATE_RULE）更新规则 [参考 UPDATE_RULE_*] */
	@JdbcResultSetMapping("UPDATE_RULE")
	private String updateRule;
	/** deleteRule：（DELETE_RULE）删除规则 [参考 DELETE_RULE_*] */
	@JdbcResultSetMapping("DELETE_RULE")
	private String deleteRule;
	/** pkName：（PK_NAME）主键名 */
	@JdbcResultSetMapping("PK_NAME")
	private String pkName;
	/** fkName：（FK_NAME）外键名 */
	@JdbcResultSetMapping("FK_NAME")
	private String fkName;
	/** deferrability：（DEFERRABILITY）can the evaluation of foreign key constraints be deferred until commit */
	@JdbcResultSetMapping("DEFERRABILITY")
	private String deferrability;

	/** [参考 {@link #pkCatalog}] */
	public String getPkCatalog() {
		return this.pkCatalog;
	}

	/** [参考 {@link #pkCatalog}] */
	public void setPkCatalog(String pkCatalog) {
		this.pkCatalog = pkCatalog;
	}

	/** [参考 {@link #pkSchema}] */
	public String getPkSchema() {
		return this.pkSchema;
	}

	/** [参考 {@link #pkSchema}] */
	public void setPkSchema(String pkSchema) {
		this.pkSchema = pkSchema;
	}

	/** [参考 {@link #pkTableName}] */
	public String getPkTableName() {
		return this.pkTableName;
	}

	/** [参考 {@link #pkTableName}] */
	public void setPkTableName(String pkTableName) {
		this.pkTableName = pkTableName;
	}

	/** [参考 {@link #pkColumnName}] */
	public String getPkColumnName() {
		return this.pkColumnName;
	}

	/** [参考 {@link #pkColumnName}] */
	public void setPkColumnName(String pkColumnName) {
		this.pkColumnName = pkColumnName;
	}

	/** [参考 {@link #fkCatalog}] */
	public String getFkCatalog() {
		return this.fkCatalog;
	}

	/** [参考 {@link #fkCatalog}] */
	public void setFkCatalog(String fkCatalog) {
		this.fkCatalog = fkCatalog;
	}

	/** [参考 {@link #fkSchema}] */
	public String getFkSchema() {
		return this.fkSchema;
	}

	/** [参考 {@link #fkSchema}] */
	public void setFkSchema(String fkSchema) {
		this.fkSchema = fkSchema;
	}

	/** [参考 {@link #fkTableName}] */
	public String getFkTableName() {
		return this.fkTableName;
	}

	/** [参考 {@link #fkTableName}] */
	public void setFkTableName(String fkTableName) {
		this.fkTableName = fkTableName;
	}

	/** [参考 {@link #fkColumnName}] */
	public String getFkColumnName() {
		return this.fkColumnName;
	}

	/** [参考 {@link #fkColumnName}] */
	public void setFkColumnName(String fkColumnName) {
		this.fkColumnName = fkColumnName;
	}

	/** [参考 {@link #sequenceNumber}] */
	public String getSequenceNumber() {
		return this.sequenceNumber;
	}

	/** [参考 {@link #sequenceNumber}] */
	public void setSequenceNumber(String sequenceNumber) {
		this.sequenceNumber = sequenceNumber;
	}

	/**
	 * <pre>
	 * [参考 {@link #sequenceNumber}]
	 * 
	 * 兼容不同数据库返回值
	 * </pre>
	 */
	public void setSequenceNumber(double sequenceNumber) {
		this.sequenceNumber = CastCommons.numberToString(sequenceNumber);
	}

	/**
	 * <pre>
	 * [参考 {@link #sequenceNumber}]
	 * 
	 * 兼容不同数据库返回值
	 * </pre>
	 */
	public void setSequenceNumber(long sequenceNumber) {
		this.sequenceNumber = CastCommons.numberToString(sequenceNumber);
	}

	/**
	 * <pre>
	 * [参考 {@link #sequenceNumber}]
	 * 
	 * 兼容不同数据库返回值
	 * </pre>
	 */
	public void setSequenceNumber(int sequenceNumber) {
		this.sequenceNumber = CastCommons.numberToString(sequenceNumber);
	}

	/**
	 * <pre>
	 * [参考 {@link #sequenceNumber}]
	 * 
	 * 兼容不同数据库返回值
	 * </pre>
	 */
	public void setSequenceNumber(short sequenceNumber) {
		this.sequenceNumber = CastCommons.numberToString(sequenceNumber);
	}

	/** [参考 {@link #updateRule}] */
	public String getUpdateRule() {
		return this.updateRule;
	}

	/** [参考 {@link #updateRule}] */
	public void setUpdateRule(String updateRule) {
		this.updateRule = updateRule;
	}

	/**
	 * <pre>
	 * [参考 {@link #updateRule}]
	 * 
	 * 兼容不同数据库返回值
	 * </pre>
	 */
	public void setUpdateRule(double updateRule) {
		this.updateRule = CastCommons.numberToString(updateRule);
	}

	/**
	 * <pre>
	 * [参考 {@link #updateRule}]
	 * 
	 * 兼容不同数据库返回值
	 * </pre>
	 */
	public void setUpdateRule(long updateRule) {
		this.updateRule = CastCommons.numberToString(updateRule);
	}

	/**
	 * <pre>
	 * [参考 {@link #updateRule}]
	 * 
	 * 兼容不同数据库返回值
	 * </pre>
	 */
	public void setUpdateRule(int updateRule) {
		this.updateRule = CastCommons.numberToString(updateRule);
	}

	/**
	 * <pre>
	 * [参考 {@link #updateRule}]
	 * 
	 * 兼容不同数据库返回值
	 * </pre>
	 */
	public void setUpdateRule(short updateRule) {
		this.updateRule = CastCommons.numberToString(updateRule);
	}

	/** [参考 {@link #deleteRule}] */
	public String getDeleteRule() {
		return this.deleteRule;
	}

	/** [参考 {@link #deleteRule}] */
	public void setDeleteRule(String deleteRule) {
		this.deleteRule = deleteRule;
	}

	/**
	 * <pre>
	 * [参考 {@link #deleteRule}]
	 * 
	 * 兼容不同数据库返回值
	 * </pre>
	 */
	public void setDeleteRule(double deleteRule) {
		this.deleteRule = CastCommons.numberToString(deleteRule);
	}

	/**
	 * <pre>
	 * [参考 {@link #deleteRule}]
	 * 
	 * 兼容不同数据库返回值
	 * </pre>
	 */
	public void setDeleteRule(long deleteRule) {
		this.deleteRule = CastCommons.numberToString(deleteRule);
	}

	/**
	 * <pre>
	 * [参考 {@link #deleteRule}]
	 * 
	 * 兼容不同数据库返回值
	 * </pre>
	 */
	public void setDeleteRule(int deleteRule) {
		this.deleteRule = CastCommons.numberToString(deleteRule);
	}

	/**
	 * <pre>
	 * [参考 {@link #deleteRule}]
	 * 
	 * 兼容不同数据库返回值
	 * </pre>
	 */
	public void setDeleteRule(short deleteRule) {
		this.deleteRule = CastCommons.numberToString(deleteRule);
	}

	/** [参考 {@link #pkName}] */
	public String getPkName() {
		return this.pkName;
	}

	/** [参考 {@link #pkName}] */
	public void setPkName(String pkName) {
		this.pkName = pkName;
	}

	/** [参考 {@link #fkName}] */
	public String getFkName() {
		return this.fkName;
	}

	/** [参考 {@link #fkName}] */
	public void setFkName(String fkName) {
		this.fkName = fkName;
	}

	/** [参考 {@link #deferrability}] */
	public String getDeferrability() {
		return this.deferrability;
	}

	/** [参考 {@link #deferrability}] */
	public void setDeferrability(String deferrability) {
		this.deferrability = deferrability;
	}

	/**
	 * <pre>
	 * [参考 {@link #deferrability}]
	 * 
	 * 兼容不同数据库返回值
	 * </pre>
	 */
	public void setDeferrability(double deferrability) {
		this.deferrability = CastCommons.numberToString(deferrability);
	}

	/**
	 * <pre>
	 * [参考 {@link #deferrability}]
	 * 
	 * 兼容不同数据库返回值
	 * </pre>
	 */
	public void setDeferrability(long deferrability) {
		this.deferrability = CastCommons.numberToString(deferrability);
	}

	/**
	 * <pre>
	 * [参考 {@link #deferrability}]
	 * 
	 * 兼容不同数据库返回值
	 * </pre>
	 */
	public void setDeferrability(int deferrability) {
		this.deferrability = CastCommons.numberToString(deferrability);
	}

	/**
	 * <pre>
	 * [参考 {@link #deferrability}]
	 * 
	 * 兼容不同数据库返回值
	 * </pre>
	 */
	public void setDeferrability(short deferrability) {
		this.deferrability = CastCommons.numberToString(deferrability);
	}

	@Override
	public int compareTo(DatabaseForeignKey o) {
		return this.getSequenceNumber().compareTo(o.getSequenceNumber());
	}

}
